package com.demo.exception.utils.verification;


import cn.hutool.core.util.PhoneUtil;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @Description 手机号码验证 调用了hutool的工具包
 * @Author 小乌龟
 * @Date 2022/3/2 16:15
 */
public class IsPhoneValidation implements ConstraintValidator<IsPhone, String> {

    @Override
    public void initialize(IsPhone constraintAnnotation) {
        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
            return PhoneUtil.isMobile(value);
    }
}
